const express = require("express");
const app = express();

const alipayConfig = require("./alipay_config.js");

const AlipaySdk = require("alipay-sdk").default;
const alipaySdk = new AlipaySdk(alipayConfig.AlipayBaseConfig);

app.get("/", async (req, res) => {
  const result = await alipaySdk.pageExec("alipay.trade.page.pay", {
    bizContent: {
      // 商家自定义订单号，每次测试都要改一次，不能重复
      out_trade_no: "121212123123123",
      // 支付金额
      total_amount: "6666",
      subject: "测试订单",
      product_code: "FAST_INSTANT_TRADE_PAY",
    },
  });
  console.log(result);
  res.send(result);
});

app.listen(80, () => {
  console.log("listening at port 80");
});
